/**
 * 
 */
package cc.dogtailflower.framework.util;

import java.net.URLDecoder;
import java.net.URLEncoder;

import cc.dogtailflower.framework.exception.AppException;

/**
 * URL编解码操作工具类
 * @author cc
 *
 */
public class CodeUtil {

	/*
	 * URL UTF8编码
	 */
	public static String encodeURL(String source){
		String des;
		try{
			des = URLEncoder.encode(source, "UTF-8");
		}catch(Exception e){
			e.printStackTrace();
			throw new AppException(e.getMessage());
		}
		return des;
	}
	
	/*
	 * URL UTF8解码
	 */
	public static String decodeURL(String source){
		String des;
		try{
			des = URLDecoder.decode(source, "UTF-8");
		}catch(Exception e){
			e.printStackTrace();
			throw new AppException(e.getMessage());
		}
		return des;
	}
}
